#!/bin/bash

function releasePort(){
    portID=$1
    result=`lsof -i :${portID}`
    result="${result}"

    if [ -z "${result}" ]
    then
        echo "端口未占用"
    else
        echo -e "端口已占用, details:\n${result}"
        select_pos=10
        i=0
        processID=""
        for elem in ${result}
        do
            # echo ${elem}
            if [ $i -eq ${select_pos} ]
            then
                processID=${elem}
                break
            fi
            i=$(expr $i + 1)
        done
        echo "占用进程ID:${processID}"
        kill -KILL ${processID}
        echo "已解除占用√"
    fi
}


releasePort 9090